﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace BlackHtml5.WebSite.Models.BLL
{
    public class GlobalData
    {
        public Dictionary<string,string> GetSysConfig(System.Data.IDbConnection conn)
        {
            
            Dictionary<string, string> global = (Dictionary<string, string>)System.Runtime.Caching.MemoryCache.Default.Get("db:sys_config");
            if (global == null)
            {
                global = new Dictionary<string, string>();
                var con = Models.Common.GetConnection(conn);
                var configs = con.QueryAll("select * from sys_config");
                foreach (var c in configs)
                {
                    global.Add(c.name, c.value);
                }
                System.Runtime.Caching.MemoryCache.Default.Add("db:sys_config", global, DateTimeOffset.Now.AddHours(5));
            }
            return global;
        }
    }
}